import axios from '@/utils/request'

//获取表单数据
export const getTabelDataAsync = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/user/list?currPage=${currPage}&pageSize=${pageSize}&key=${key}`, params)
}

// 添加用户
export const addUserAysnc = (params) => {
  return axios.post('/lanlu/user/save', params)
}

//获取更新用户数据
export const getUserInfoAsync = (params) => {
  const { id } = params
  return axios.get(`/lanlu/user/goUpdateUserPage?id=${Number(id)}`)
}

//更新用户
export const updateUserInfoAsync = (params) => {
  return axios.post('/lanlu/user/update', params)
}


//删除用户
export const deleteUserAysnc = (params) => {
  const { id } = params
  return axios.delete(`/lanlu/user/deleteUser/${id}`)
}

//分配角色 获取用户的角色数据
export const getUserRolesAysnc = (params) => {
  const { id } = params
  return axios.get(`/lanlu/user/allocateRole?id=${id}`)
}

//分配角色  更新角色
export const updateAllocateRolesAsync = (params) => {
  return axios.post('/lanlu/user/saveUserAndRole', params)
} 